home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 7_9.lha / 7_9 / tst.c < prev    next >
Text File  |  1993-08-08  |  1KB  |  62 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. include <stream.h>
  6.  
  7. include "7_9.h"
  8. include "nlink.h"
  9. include "7_9_dlist.h"
  10.  
  11. ain()
  12.  
  13.    dlist xdlist;
  14.  
  15. *
  16.    nlink i1("ins 1");
  17.    xdlist.insert(&i1);
  18.    nlink a1("app 1");
  19.    xdlist.append(&a1);
  20.  
  21.    nlink i2("ins 2");
  22.    xdlist.insert(&i2);
  23.    nlink a2("app 2");
  24.    xdlist.append(&a2);
  25. /
  26.  
  27.    nlink hello("hello");
  28.    xdlist.insert(&hello);
  29.    nlink there("there");
  30.    xdlist.insert(&there);
  31.    nlink how("how");
  32.    xdlist.insert(&how);
  33.    nlink are("are");
  34.    xdlist.insert(&are);
  35.    nlink you("you");
  36.    xdlist.append(&you);
  37.    nlink today("today");
  38.    xdlist.insert(&today);
  39.  
  40.    nlink *x;
  41.    cout << "forwards\n";
  42.    while (xdlist.next(x))
  43. cout << "'" << (char*)x->x << "'\n";
  44.    cout << "\nbackwards\n";
  45.    while (xdlist.prev(x))
  46. cout << "'" << (char*)x->x << "'\n";
  47.    xdlist.next(x);
  48.    xdlist.next(x);
  49.    nlink Beep("Beep");
  50.    xdlist.inserthere(&Beep);
  51.    nlink Boop("Boop");
  52.    xdlist.appendhere(&Boop);
  53.    xdlist.reset();
  54.    cout << "\nforwards, removing\n";
  55.    while (xdlist.getnext(x))
  56. cout << "'" << (char*)x->x << "'\n";
  57.    cout << "\nbackwards\n";
  58.    while (xdlist.getprev(x))
  59. cout << "'" << (char*)x->x << "'\n";
  60.    return 0;
  61.  
  62.